﻿using System.Collections.Generic;
using DataAccess;
using EnglishLibrary;

namespace DataTransfer
{
    public class CategoryDT
    {
        //The object for invoking methods
        private readonly CategoryDAO cateDAO;

        public CategoryDT()
        {
            cateDAO = new CategoryDAO();
        }

        public CategoryDT(string filePath)
        {
            cateDAO = new CategoryDAO(filePath);
        }

        /// <summary>
        /// Get list categories from database
        /// </summary>
        /// <returns>list of categories</returns>
        public List<Category> GetListCategories()
        {
            return cateDAO.GetListCategories();
        }

        /// <summary>
        /// Get cate by name
        /// </summary>
        /// <param name="name">the name of the cate</param>
        /// <returns>cate or null</returns>
        public Category GetCateByName(string name)
        {
            return cateDAO.GetCateByName(name);
        }

        /// <summary>
        /// Get cate by Id
        /// </summary>
        /// <param name="name">the id of the cate</param>
        /// <returns>cate or null</returns>
        public Category GetCateById(int id)
        {
            return cateDAO.GetCateById(id);
        }

        /// <summary>
        /// Insert new category into database
        /// </summary>
        /// <param name="cateItem">the object that holds information</param>
        /// <returns>success or fail</returns>
        public bool InsertItem(Category cateItem)
        {
            return cateDAO.InsertItem(cateItem);
        }

        public string FilePath
        {
            get { return cateDAO.FilePath; }
            set { cateDAO.FilePath = value; }
        }
    }
}
